﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CRM.Database.Model;

namespace CRM.Syncroniser
{
  public   class ChangeManager:ISyncronise
    {
      #region Implementation of ISyncronise

      /// <summary>
      /// Запуск синхронизации
      /// </summary>
      /// <returns>Результат запуска</returns>
      public bool Syncronise()
      {

          int oldManagerId = 12;
          int newManagerId = 578;
          var col = new CustomersCollection();

          foreach(var customer in col.CustomersList)
          {
              if(customer.IdManager==oldManagerId)
              {
                  customer.IdManager = newManagerId;
                  if(!col.Update(customer,"max"+DateTime.Now.ToShortDateString()))
                      return false;
              }
          }

          


          return true;
      }

      #endregion
    }
}
